const windowSize = ({ zoomStyle, width, height }, innerWidth, innerHeight) => {
  let widthPre = width;
  let heightPre = height;

  let scaleX = 1;
  let scaleY = 1;

  if (zoomStyle === 'screenFull') {
    scaleX = Math.floor((innerWidth / width) * 10000) / 10000;
    scaleY = Math.floor((innerHeight / height) * 10000) / 10000;
    widthPre = innerWidth;
    heightPre = innerHeight;
  }
  if (zoomStyle === 'widthFull') {
    scaleX = Math.floor((innerWidth / width) * 10000) / 10000;
    scaleY = scaleX;
    widthPre = innerWidth;
    heightPre = scaleX * height;
  }
  if (zoomStyle === 'heightFull') {
    scaleY = Math.floor((innerHeight / height) * 10000) / 10000;
    scaleX = scaleY;
    heightPre = innerHeight;
    widthPre = scaleY * width;
  }

  return {
    innerWidth,
    innerHeight,
    widthPre,
    heightPre,
    scaleX,
    scaleY,
  };
};

export const previewWindowSize = ({ zoomStyle, width, height }) => {
  const innerWidth = window.innerWidth || document.documentElement.clientWidth;
  const innerHeight = window.innerHeight || document.documentElement.clientHeight;

  return windowSize({ zoomStyle, width, height }, innerWidth, innerHeight);
};
